package com.opgea.tutor.domain.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 * Entity implementation class for Entity: Tutor
 * 
 */
@Entity
@DiscriminatorValue(value = "T")
public class Tutor extends Person implements Serializable {

    private static final long serialVersionUID = 1L;

    @OneToMany(fetch = FetchType.LAZY)
    private Collection<Specialization> specializations = new ArrayList<Specialization>();

    @OneToMany(fetch = FetchType.LAZY)
    private Collection<Education> educations = new ArrayList<Education>();

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "tutor")
    private Collection<TutorDocument> documents = new ArrayList<TutorDocument>();

    @OneToOne
    private Login login;
    @OneToOne
    private Location location;

    public void addSpecialization(Specialization specialization) {
	if (specializations != null) {
	    specializations.add(specialization);
	} else {
	    specializations = new ArrayList<Specialization>();
	    specializations.add(specialization);
	}
    }

    public void addEducation(Education education) {
	if (educations != null) {
	    educations.add(education);
	} else {
	    educations = new ArrayList<Education>();
	    educations.add(education);
	}
    }

    public void addDocument(TutorDocument document) {
	if (documents != null) {
	    documents.add(document);
	} else {
	    documents = new ArrayList<TutorDocument>();
	    documents.add(document);
	}
    }

    public Login getLogin() {
	return login;
    }

    public void setLogin(Login login) {
	this.login = login;
    }

    public Location getLocation() {
	return location;
    }

    public void setLocation(Location location) {
	this.location = location;
    }

    public Collection<Specialization> getSpecializations() {
	return specializations;
    }

    public void setSpecializations(Collection<Specialization> specializations) {
	this.specializations = specializations;
    }

    public Collection<Education> getEducations() {
	return educations;
    }

    public void setEducations(Collection<Education> educations) {
	this.educations = educations;
    }

    public Collection<TutorDocument> getDocuments() {
	return documents;
    }

    public void setDocuments(Collection<TutorDocument> documents) {
	this.documents = documents;
    }

}
